package books.ThinkingInJava.src.Chapter18;

import books.ThinkingInJava.src.Tools.Output;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Arrays;

/**
 * @author bloodcolding
 * @since 12/29/2018 2:32 PM
 */
public class TestDoubleBuffer {
    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[12]);
        IntBuffer intBuffer = byteBuffer.asIntBuffer();
        intBuffer.put(111);
        Output.println(Arrays.toString(intBuffer.array()));
        intBuffer.rewind();
        int i = 0;
        intBuffer.rewind();
        while (intBuffer.hasRemaining()) {
            Output.println((i = intBuffer.get()));
        }
        Output.println(Arrays.toString(intBuffer.array()));
    }
}

